/**
Author: Maciej Oczko
Date: November 2011
*/

#ifndef TESTDATA_H_
#define TESTDATA_H_

#include <iostream>
#include <ctime>

//#define OUT 1

// Debug logging
#ifdef OUT
	#define log(s) do { std::cout << __FUNCTION__ << ":: " << s << std::endl; } while(0)
#else
	#define log(s) ((void)0)
#endif

// Test structures

struct TestStruct1
{
	char c1, c2;
	int i1;
	float f1;
};

struct TestStruct2
{
	int i1;
	TestStruct1 ts1;
};


// Print elapsed time
void printTime(clock_t start, clock_t stop);

// Heap test
template<typename T>
void HeapTestFunction(unsigned random)
{
	log(typeid(T).name() << " objects (object size: " << sizeof(T) << ").");

	std::vector<T *> vec;

	// Get some
	for(unsigned i = 0; i < random; ++i)
	{
		T * ptr = (T*) new T();
		//log("[" << i << "] alloc address: " << ptr);
		vec.push_back(ptr);
	}

	log("Used count: " << vec.size());
	log("Used size: " << vec.size() * sizeof(T));

	log("Freeing...");

	// Free some
	for(unsigned i = 0; i < vec.size(); ++i)
	{
		T * ptr = vec.back();
		vec.pop_back();
		//log("[" << i << "] free address: " << ptr);
		delete ptr;
	}

	log("Used count: " << vec.size());
	log("Used size: " << vec.size() * sizeof(T));
}

#endif